/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sgsmcan.Dao;

import com.sgsmcan.Entidad.Evento;
import com.sgsmcan.Hibernate.HibernateUtil;
import com.sgsmcan.Utils.Utilitario;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;

/**
 *
 * @author user
 */
public class EventoDaoImpl extends HibernateDao<Evento> implements EventoDao<Evento>{

    private final String  CLASE_EVENTO = "[EventoDaoImpl]";
    
    @Override
    public List<Evento> getEventos() {
        Session session = null;
        List<Evento> auxiliar = null;
        try{
            session = HibernateUtil.getSessionFactory().openSession();
            Criteria cri = session.createCriteria(Evento.class,"evnto").createAlias("evnto.tipo","tipoEvento");
            auxiliar = cri.list();
        }catch(HibernateException e){
           Utilitario.LOG.error(CLASE_EVENTO+ " Error al obtener los tipos de Eventos ", e);
           e.printStackTrace();
        }finally{
            if(session!= null){
                session.close();
            }
        }
        return auxiliar;
    }
    
}
